<?php
/**
 * Created by PhpStorm.
 * User: syzhou
 * Date: 2020-11-12
 * Time: 20:07
 *
 * 该脚本将 2019年度科技奖申报项目的附件，安装到2020年度科技奖系统
 */

require_once __DIR__ . '/file.php';

$srcHome = '/root/upload';
$dstHome = '/root/www/award2020.chhca.org.cn/public/upload';

$srcSubDirs = scandir($srcHome);
$i = 1;
foreach ($srcSubDirs as $srcSubDir) {
    if (!preg_match('/^\d{8}$/', $srcSubDir)) {
         continue;
    }
    $srcDir = "$srcHome/$srcSubDir";
    $dstDir = "$dstHome/$srcSubDir";
    echo "$i. copying from '$srcDir' to '$dstDir'\n";
    $i++;
    $copyDirResultCode = copyDir($srcDir, $dstDir);
    if (0 != $copyDirResultCode) {
        echo "failed(result code: $copyDirResultCode). stop.";
        exit(-1);
    }
}